#if !defined(AFX_MYGRAPHVIEW_H__A75713A1_5EB6_47FB_8DEB_83C263BE74BF__INCLUDED_)
#define AFX_MYGRAPHVIEW_H__A75713A1_5EB6_47FB_8DEB_83C263BE74BF__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// MyGraphView.h : header file
//
#define NORMALTOOL	0
#define ZOOMTOOL	1
#define SCROLLTOOL  2
#define ZOOM_MULTIPLIER 0.3
#define RIGHT 1
#define LEFT 0
/////////////////////////////////////////////////////////////////////////////
// MyGraphView view
struct SCROLLINFO64
{
	UINT cbSize; 
	UINT fMask; 
	__int64 nMin; 
	__int64 nMax; 
	UINT64 nPage; 
	__int64 nPos; 
	__int64 nTrackPos; 
};

class GraphView : public CScrollView
{
private:
	int SelectedScenario;
protected:
	GraphView();           // protected constructor used by dynamic creation
	DECLARE_DYNCREATE(GraphView)
	__int64						GraphWindowIndent;
	SCROLLINFO64				HorSi64;

	long						GraphVerticalScrollPosition;
	const static long			GraphWindowDivider = 3;

	BOOL						WindowIsOpened;
	CToolTipCtrl				m_ToolTip; 
	CString						LastTipText;
	CString						CurrentTipText;
	bool						GridVisible;

//  linesforselectionstatus ==	0 no line to show
//	linesforselectionstatus	==	1 one line with cursor
//	linesforselectionstatus	==	2 there is selected area no line with cursor
//	linesforselectionstatus	==	3 there is selected area with corsor line
	// Attributes
public:
	friend	class		ZWaveeditorDoc;
	friend  class		CImage;
	ZWaveeditorDoc*		GetDocument();
public:
	CPoint				mypoint;
	CClientDC*			myDC;

// Operations
public:
	void				DrawRightLineCursor			(int x);
	void				DrawLineCursorSimple		(int x);
	void				DrawLineCursorInClock		(int x);
	void				DrawSelectedArea			(CPoint p1,CPoint p2);
	void				DrawSelectedArea			(CDC *pDC,CRect rect);
	void				SetSignalBackgroundColor	( CDC* pDC, COLORREF SignalBackgroundColor, CRect SignalBackgroundArea, int NumberOfSignal, graphdata *GraphData );
	void				DrawRectangleInColor		( CDC* pDC, CRect Rect, COLORREF BrushColor, COLORREF PenColor );
	void				DrawRedBar					(CDC *pDC, CRect SignalBackgroundArea );
	void				DrawGreenBar				(CDC *pDC, CRect SignalBackgroundArea );
	void				DrawLineCursor				(int x);
	void				DrawMarkCursor				(CDC* pDC, int x,COLORREF color);
	void				UpDateGraph					();
	void				UpdateClockGraph			();
	void				UpdateInfoView				();
	int					ReadGraphData				(CDC* pDC);
private:
	void				DrawSignal					(CDC* pDC, int NumberOfSignal, CPoint* sigp, CPen **pen, CBrush **brush, graphdata *GraphData);
	void				DrawVerGrid					( ZWaveeditorDoc*& pDoc, int HorizontalWindowSize, int Height, CDC* pDC, int IndentOfGraphFromWindow );
	void				DrawHorGridLine				(CDC* pDC, int WindowHorizontalSize, int IndentOfGraphFromWindow, int Height );


	HCURSOR				SetupCursor					( BYTE CursorType );
	void				ScrollViewTarget			( CPoint OldPoint, CPoint NewPoint );
	void				UpdateButtonView			();
	void				SetGraphDataAndUpdateViews( __int64 StartPositionOfVisibleGraphArea,
													__int64 SizeOfVisibleGraphArea );
	BOOL				SetScrollInfo64( int     nBar, 
										SCROLLINFO64 &Si, 
										BOOL    fRedraw = 1
										);
	__int64				GetScrollTrackPos64( int     nBar, 
										int     fMask, 
										UINT64  nMax64);
	// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(MyGraphView)
	public:
/*	virtual BOOL OnScroll(UINT nScrollCode, UINT nPos, BOOL bDoScroll = TRUE);*/
	protected:
	virtual void OnDraw(CDC* pDC);      // overridden to draw this view
	virtual void OnInitialUpdate();     // first time after construct
	virtual void OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint);
	virtual void OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView);
	//}}AFX_VIRTUAL

// Implementation
protected:
	ChildGraphFrame * GetParentGraphFrame();
	void			ChangeWindowTitle();
	virtual			~GraphView();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

	// Generated message map functions
	//{{AFX_MSG(MyGraphView)
	afx_msg void OnKillFocus(CWnd* pNewWnd);
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg LRESULT OnMouseLeave(WPARAM wparam, LPARAM lparam);
	afx_msg void OnDestroy();
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
/*	afx_msg BOOL OnEraseBkgnd(CDC* pDC);*/
	afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
public:
	afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
	afx_msg void OnWindowPosChanging(WINDOWPOS* lpwndpos);
	//int PrepearSetMarkMenu(CPoint mpoint);
protected:
	//virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
	BOOL PreTranslateMessage(MSG* pMsg); 
	void OnGraphMouseMove(CPoint mousepoint);
	void CatchMouseLeaveWindowArea();
	BOOL InitialSetScrollInfo();
	BOOL InitialSetHorizontalScrollInfo();
	BOOL SetVerticalScrollInfo();
	long GetStartDrawingMarkCursorPosition( long WindowCoordinateFromGraph );
	void NormalizeScrollPosition( SCROLLINFO64 *ScrollInfo );
	void NormalizeScrollPage( SCROLLINFO64 *ScrollInfo );
	__int64 GetPositionOfGraphAreaFromScrollInfo( SCROLLINFO64 ScrollInfo );
	BOOL IsBoundaryGraphPositionReached( __int64 NewPositionOfVisibleGraphArea );
	//long GetPositionOfScrollInfoFromPositionOfVisibleGraphArea( long NewPositionOfVisibleGraphArea, SCROLLINFO ScrollInfo );
	//long GetSizeOfGraphAreaFromScrollInfo( SCROLLINFO ScrollInfo );
	void NormalizeZoomingBorders();
	void Zoomout( double ZoomMultiplier );
	ResultWaveSignalStatistics GetSignalsStatistics( CString SignalName );
	__int64 GetStartDrawingCoordinateX();
	__int64 ComputeGraphWindowIndentFromPageSize( __int64 PageSize );
	void OnToolTipNeedText( bool bAlwaysShowHint );

public:
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
	int OnMouseZoomIn();
	int SetGraphInfoAfterZoomIn( SCROLLINFO64 ScrollInfo );
	afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
	void		 PutMark1	(CPoint mpoint);
	void		 PutMark2	(CPoint mpoint);
	void		 SnapMark1	(CPoint mpoint);
	void		 SnapMark2	(CPoint mpoint);
	afx_msg void OnRButtonDblClk(UINT nFlags, CPoint point);
	afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
	afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
	afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
	afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
	void OnShift( BYTE ShiftDirection );
	void OnZoomin();
	void OnZoomout();
   
	void OnChooseColor();
	void OnGroupWaves();
	void OnUnGroup();

    void SetVisibleOrInvisibleGrid();

	void OnChangeMsUs();
	void OnSetHighlightingRules();
	SCROLLINFO GetVertScrollInfo();
	SCROLLINFO64 GetHorzScrollInfo();
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	void OnRemoveSignals();
	void OnAddSignals();
	void Refresh();
	void GetWholeGraphChart( CImage *ImageForSave, graphdata *ImageGraphData );
	int DrawWholeGraphChart( CDC *pDC, graphdata *ImageGraphData );
	__int64 GetScrollSizeWithoutIndents();
	long GetIndentOfGraphFromWindow();
	CString GetOriginalTimeType();
	void OnDeletePermanently();
	void OnReloadLogWithChosenProperties();
	bool SourceIsLog();
	void DisplaceToFirstChangeAndMaxZoomin();
};

#define QUANTITY_HYPHENS 14

/////////////////////////////////////////////////////////////////////////////
#ifndef _DEBUG  // debug version in waveeditorView.cpp
inline ZWaveeditorDoc* GraphView::GetDocument()
   { return (ZWaveeditorDoc*)m_pDocument; }
#endif

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_MYGRAPHVIEW_H__A75713A1_5EB6_47FB_8DEB_83C263BE74BF__INCLUDED_)
